//
//  PublishController.m
//  soccer
//
//  Created by 上官千城 on 15/9/7.
//  Copyright (c) 2015年 上官千城. All rights reserved.
//

#import "PublishController.h"

@interface PublishController ()

@end

@implementation PublishController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.navigationItem.title = @"发布资讯";

    //左侧按钮
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setBackgroundImage:[UIImage imageNamed:@"资讯详情页_18@2x"]forState:UIControlStateNormal];
    [button addTarget:self action:@selector(leftBarButtonItemAction)
     forControlEvents:UIControlEventTouchUpInside];
    button.frame = CGRectMake(0, 0, 40, 40);
    UIBarButtonItem *left = [[UIBarButtonItem alloc] initWithCustomView:button];
    self.navigationItem.leftBarButtonItem = left;
    
    
    //右侧按钮
    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
    [button1 setBackgroundImage:[UIImage imageNamed:@"资讯详情页_18-02@2x"]forState:UIControlStateNormal];
    [button1 addTarget:self action:@selector(rightBarButtonItemAction)
      forControlEvents:UIControlEventTouchUpInside];
    button1.frame = CGRectMake(0, 0, 40, 40);
    UIBarButtonItem *right = [[UIBarButtonItem alloc] initWithCustomView:button1];
    self.navigationItem.rightBarButtonItem = right;
    
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT) style:UITableViewStyleGrouped];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
//    
//    UIView *aView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, 200)];
//    aView.backgroundColor = [UIColor greenColor];
//    
//    self.addImage = [[UIImageView alloc]initWithFrame:CGRectMake(10, 30, 70, 70)];
//    self.addImage.image = [UIImage imageNamed:@"添加图片@2x"];
//    [aView addSubview:self.addImage];
//    
//    self.tableView.tableHeaderView = aView;
    
    
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 3;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//    if (indexPath.section == 0 && indexPath.row == 0) {
//        return nil;
//    }
    if (indexPath.section == 0 ) {
    static NSString *cellInfo = @"settingCell";
    PublishCell *cell = [tableView dequeueReusableCellWithIdentifier:cellInfo];
    if (cell == nil) {
        cell = [[PublishCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellInfo];
    }
    return cell;
    }
    if (indexPath.section == 1) {
        static NSString *cellinfo = @"textCell";
        PublishCell *cell = [[PublishCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellinfo];
        return cell;
    }
    if (indexPath.section == 2) {
        static NSString *cellPublish = @"publishCell";
        PublishCell *cell = [[PublishCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellPublish];
        return cell;
    }
    return nil;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
//    if (section == 0) {
//        return 2;
//    }
    return 1;

}
//行高
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        return 120;
    }
    if (indexPath.section == 1) {
        return 200;
    }
    return 50;

}
//右侧按钮使用说明
-(void)rightBarButtonItemAction
{
    UsageController *view = [[UsageController alloc]init];
    [self.navigationController pushViewController:view animated:YES];
}
//左侧按钮返回
-(void)leftBarButtonItemAction
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
